package median;

import java.io.File;


import org.junit.Test;

import common.IMS_CSV_File;
import common.ImageMethods;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.*;


public class ValidateSpeedMedian {

	@Test
	public void validate() {
	
		File folder = new File("E:/_IPHEx CBF/ims_files/");
		File[] listFiles = folder.listFiles();
		int max = 20;
		int i = 0;
		for (File file : listFiles) {
			IMS_CSV_File imsFile = new IMS_CSV_File(file);
			double[][] sourceMap = imsFile.getMap();
			
			int maskSize = 5;
			double[][] actual = ForkJoinFastMedian.forkJoinFastMedian(sourceMap, maskSize);
			double[][] expected = ImageMethods.filterMedian(sourceMap, maskSize);		
			
			System.out.println("");
			assertNotNull(expected);
			assertNotNull(actual);
			assertArrayEquals(expected, actual);
			i++;
		//	if(i >= max) break;
		}
		System.out.println(i+" Files tested");
		
//		IMS_CSV_File imsFile = new IMS_CSV_File(new File("E:/_IPHEx CBF/ims_files/NI24_0909171332_ims.csv"));
//		double[][] sourceMap = imsFile.getMap();
//		
//		double[][] expected = ImageMethods.filterMedian(sourceMap, 5);		
//		double[][] actual = ForkJoinFastMedian.forkJoinFastMedian(sourceMap);
//
//		
//		assertArrayEquals(expected, actual);

	}
	
}
